<?php
/**
 * mxn数组变换
 * Created by PhpStorm.
 * User: ywf
 * Date: 2015/11/4
 * Time: 17:20
 */
?>
<pre>
<form method="post">
    <table>
        <tr>
            <td>m</td><td><input name="m" type="text" value="3"></td>
        </tr>
        <tr>
            <td>n</td><td><input name="n" type="text" value="2"></td>
        </tr>
        <tr>
            <td colspan="2"><input name="submit" type="submit" value="提交"/></td>
        </tr>
    </table>
</form>
<?
$m=isset($_GET['m'])?$_GET['m']:10;
$n=isset($_GET['n'])?$_GET['n']:6;
$k=1;
echo '创建原始数组:';
for($i=0;$i<=$m;$i++){
    for($j=0;$j<=$n;$j++){
        $a[$i][$j]=$k;
        $k++;
    }
}
var_dump($a);

echo '变换后的数组:';
foreach($a as $key=>$v){
    foreach($v as $jkey=>$vc){
        $b[$jkey][$key]=$vc;
    }
}
var_dump($b);
?>
